package fzdy.core.common;

/**
 * Created by Administrator on 2017/3/27 0027.
 */
public class DistanceTool {
    public DistanceTool() {
    }

    public static double getDistance(double long1, double lat1, double long2, double lat2) {
        double R = 6378137.0D;
        lat1 = lat1 * 3.141592653589793D / 180.0D;
        lat2 = lat2 * 3.141592653589793D / 180.0D;
        double a = lat1 - lat2;
        double b = (long1 - long2) * 3.141592653589793D / 180.0D;
        double sa2 = Math.sin(a / 2.0D);
        double sb2 = Math.sin(b / 2.0D);
        double d = 2.0D * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
        return d;
    }
}
